package com.chat.service;

import com.chat.view.ChatListData;
import com.chat.view.FriendListData;
import javafx.application.Platform;

import java.util.Iterator;

import static com.chat.view.MainWindowController.chat;
import static com.chat.view.MainWindowController.friend;

/*
  改变好友的在线状态
 */
public class FriendStatus {
       public void set(String userid,String status){
              Platform.runLater(new Runnable() {
                     @Override
                     public void run() {
                            int line=0;
                            Iterator<FriendListData> iter=friend.iterator();
                            while(iter.hasNext()){
                                   FriendListData fld=new FriendListData();
                                   FriendListData friendListData=(FriendListData) iter.next();
                                   System.out.println(friendListData.getId());
                                   if(friendListData.getId().equals(userid)){
                                          System.out.println(userid+"上线了");
                                          fld=friend.get(line);
                                          fld.setStatus(status);
                                          friend.remove(line);
                                          friend.add(line,fld);
                                          break;
                                   }
                                   line++;
                            }                     }
              });

       }
}
